package day01;

/**
 * <a href="https://leetcode-cn.com/problems/reverse-words-in-a-string-iii/">557. 反转字符串中的单词 III</a>
 */
public class Answer {

    public final static String word = "Let's take LeetCode contest";

    public static void main(String[] args) {
        String s = reverseWords(word);
        System.out.println(s);
    }

    public static String reverseWords(String word) {
        StringBuilder sb = new StringBuilder();
        for (String s : word.split(" ")) {
            sb.append(new StringBuilder(s).reverse()).append(" ");
        }
        return sb.deleteCharAt(word.length()).toString();
    }
}
